package com.mcb.autopublish.demos.web.service.impl;

import com.mcb.autopublish.demos.web.convert.EntityConvert;
import com.mcb.autopublish.demos.web.dto.request.ArticleQuestionMcQueryRequest;
import com.mcb.autopublish.demos.web.dto.request.ArticleQuestionMcRequest;
import com.mcb.autopublish.demos.web.dto.response.ArticleQuestionMcResponse;
import com.mcb.autopublish.demos.web.mapper.ArticleQuestionMcMapper;
import com.mcb.autopublish.demos.web.po.ArticleQuestionMc;
import com.mcb.autopublish.demos.web.service.ArticleQuestionMcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author machengbang
 * @since 2024-06-12
 */
@Service
public class ArticleQuestionMcServiceImpl implements ArticleQuestionMcService {

    @Resource
    private ArticleQuestionMcMapper articleQuestionMcMapper;

    /**
   * 查询列表
   * @param request
   * @return
   */
    @Override
    public List<ArticleQuestionMcResponse> getArticleQuestionMcList(ArticleQuestionMcQueryRequest request){
        List<ArticleQuestionMcResponse> list = articleQuestionMcMapper.getArticleQuestionMcList(request);
        return list;
    }

    /**
     * 保存
     * @param request
     * @return
     */
    @Override
    public void saveArticleQuestionMc(ArticleQuestionMcRequest request){
        ArticleQuestionMc articleQuestionMc = EntityConvert.convertToEntity(ArticleQuestionMc.class, request);
        articleQuestionMcMapper.insert(articleQuestionMc);
    }

    /**
     * 更新
     * @param request
     * @return
     */
    @Override
    public void updateArticleQuestionMc(ArticleQuestionMcRequest request){
        ArticleQuestionMc articleQuestionMc = EntityConvert.convertToEntity(ArticleQuestionMc.class, request);
        articleQuestionMcMapper.updateById(articleQuestionMc);
    }

    /**
     * 删除
     * @param request
     * @return
     */
    @Override
    public void deleteArticleQuestionMc(ArticleQuestionMcRequest request){
       articleQuestionMcMapper.deleteById(request.getId());
    }
}
